import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'
import path from 'path';

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
  const env = loadEnv(mode, process.cwd());
  return{
    plugins: [
      vue(),
      AutoImport({
        resolvers: [AntDesignVueResolver()],
      }),
      Components({
        resolvers: [AntDesignVueResolver({importStyle: false})],
      })],
      resolve: {
        alias: {
          '@': path.resolve(__dirname, './src'), // 配置 @ 指向 src 目录
        },
      },
      server: {
        host: '0.0.0.0',
        proxy: {
          [env.VITE_BASE_PATH]: {
            target: env.VITE_BASE_URL,
            changeOrigin: true,
            rewrite: (p) => p.replace(/^\/licos3/, ''),
          },
        },
      },
  }
})
